# encoding: utf-8
import os.path

rootDir = '/Users/yongli/project/heavy-energy/front/s3-sany-heavy-energy/src/app' \
          '/pages/base-data/material-template/fan-check-template/fan-check-template-detail'
oldId = '.COMPLETED'
for parent, dirnames, filenames in os.walk(rootDir):
    for filename in filenames:
        # if filename.find(oldId) != -1:
            # newname = filename.replace(oldId, '')
            newname = filename.replace("material-requirement-detail-source", "fan-check-template-detail-source")
            print(filename, "--->", newname)
            os.rename(os.path.join(parent, filename), os.path.join(parent, newname))
    #
    # for filename in dirnames:
    #     # if filename.find(oldId) != -1:
    #     # newname = filename.replace(oldId, '')
    #     newname = filename.replace("test", "farm-check")
    #     print(filename, "--->", newname)
    #     os.rename(os.path.join(parent, filename), os.path.join(parent, newname))
